<template>
  <div style="padding: 30px; text-align: left">
    <a-tabs default-active-key="1">
      <!-- <a-tab-pane key="1">
        <span slot="tab">

          区块链钱包
        </span>
        <wallet></wallet>
      </a-tab-pane> -->
      <a-tab-pane key="2" v-if="!logined">
        <span slot="tab">
          <!-- <a-icon type="android" /> -->
          用户登陆
        </span>
        <login @logined="onLogin"></login>
      </a-tab-pane>
      <a-tab-pane key="3">
        <span slot="tab">
          <!-- <a-icon type="android" /> -->
          用户信息
        </span>
        <dashborad></dashborad>
      </a-tab-pane>
    </a-tabs>
  </div>
</template>

<script>
// import Wallet from "../components/Wallet.vue";
import Login from "../components/Login.vue";
import Dashborad from "../components/Dashborad.vue";
import Constant from "../utils/Constant";

export default {
  components: { /**Wallet,*/ Login, Dashborad },
  data() {
    return {
      authorization: localStorage.getItem("authorization"),
      logined: true,
      current: 1
    };
  },
  created() {
    // this.checkLogin();
  },
  methods: {
    checkLogin() {
      let url = Constant.LOGIN_CHECK_URL;
      let params = {};
      params.authorization = this.authorization;
      this.$http.post(url, params).then(
        (resp) => {
          console.log(resp);
          if (resp.data.code === "01") {
            if (!resp.data.result) {
              localStorage.removeItem("authorization");
              this.logined = false;
            } else {
              this.logined = true;
            }
          }
        },
        (err) => {
          console.log(err);
        }
      );
    },
    onLogin(data) {
      console.log(data);
      if (data) {
        this.logined = true;
      }
    },
  },
};
</script>
